import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import { getlyric } from '../Api/Home';

export default new Vuex.Store({
  state: {
    //播放列表
    playList: [
      // {
      //   name:"肆无忌惮的爱你",
      //   picUrl : "http://p1.music.126.net/FDc-ljSKySPNQ9rdzqxAhw=-/109951168507215101.jpg"
      // },

    ],

    //播放下标
    playListIndex: 0,
    //歌曲播放/暂停状态
    btn:false,
    //控制歌词页面显示隐藏
    show:false,
    //存放歌词
    lyricList:{},
    //播放控件的歌单
    hg:50,
    //当前播放时间
    current:0
  },
  getters: {},
  mutations: {
     updatacurrent(state,value){
    state.current = value
    console.log("更新之后的时间",state.current)
     },

    updataHg(state,value){
      state.hg=value
      console.log("更新之后的高度",state.hg)
    },
    //更新歌词显示隐藏状态
    updataShow(state){
      state.show = !state.show;
    },
    //更新播放状态
    updataBtn(state,value){
      state.btn =value
    },
    //更新播放列表
    updataPlayList(state, value) {
      state.playList = value
      console.log("更新之后的播放列表", state.playList);

    },
    //更新播放下标
    updataplayListIndex(state, value) {
      state.playListIndex = value
      console.log("更新之后的播放下标", state.playListIndex);

    },
    //更新歌词
    updatalyricList(state, value){
      state.lyricList = value
      console.log('这是更新之后的歌词',state.lyricList)

    }
  },
  actions: {
  //获取歌词
  async getlyricList(context,value){
    let res = await getlyric(value)
    console.log("歌词数据",res);
    context.commit('updatalyricList',res.data.lrc)
  }
  },
  modules: {}
})
